#!/usr/bin/python
# Copyright 2009 Jeremy Pack


import datetime
import unittest
import wesabe

from transaction import Transaction

class WesabeTest(unittest.TestCase):
  def testParseWesabeXml(self):
    f = open("sample_wesabe.xml", "r")
    xml = f.read()
    f.close()
    expected_transactions = [
      Transaction(name = "ATM Withdrawal Display Name",
                  amount = 20.0,
                  date = datetime.date(2009, 6, 20),
                  tag = "jeremy"),
      Transaction(name = "ATM Withdrawal Display Name",
                  amount = 30.0,
                  date = datetime.date(2009, 6, 20),
                  tag = "family"),
      Transaction(name = "Milk Pail Market",
                  amount = 19.23,
                  date = datetime.date(2009, 6, 20),
                  tag = "groceries")]
    account = wesabe.WesabeAccount("user", "password")
    actual_transactions = account.ParseWesabeXml(xml)
    assert expected_transactions == actual_transactions, (
            "The transactions aren't correct:\nExpected: %s \nActual: %s" %
            (str(expected_transactions), str(actual_transactions)))

if __name__ == "__main__":
  unittest.main()

